//
//  ConcreateSubject.cpp
//  Observer
//
//  Created by Shane on 17/9/18.
//  Copyright © 2017年 Shane. All rights reserved.
//

#include "ConcreteSubject.h"


void ConcreteSubject::attach(Observer *observer){
    m_observerList.push_back(observer);
}

void ConcreteSubject::detach(Observer *observer){
    m_observerList.remove(observer);
}

void ConcreteSubject::notify(){
    std::list<Observer *>::iterator it = m_observerList.begin();
    while (it != m_observerList.end()) {
        (*it)->update(m_state);
        ++it;
    }
}
